<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="/struts-tags" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/bootstrap.min.css" rel="stylesheet">
<title>部门管理</title>
</head>
<style>
.margin_{
 margin: 5px;
}
</style>
<body style="background-color: rgba(187, 179, 179, 0.38);" onload="loadMessageCount()">
<div class="container">
         <jsp:include page="header.jsp"/>
<h1 class="col-sm-12" style="font-family:迷你简菱心;"><strong>会议管理系统</strong></h1>
<br><br><br>
<div class="col-sm-2">
			<div data-spy="affix" data-offset-top="160" data-offset-bottom="0">
				<ul class="nav nav-pills nav-stacked">
					<li class="dropdown"><a class="dropdown-toggle"
						data-toggle="dropdown" href="#"> 我的会议<span class="caret"></span> </a>
						<ul class="dropdown-menu">
							<li><a href="myMeetingInfo.action#future7">未来7天内的会议</a></li>
							<li><a href="myMeetingInfo.action#myOrder">我预约的会议</a></li>
							<li><a href="myMeetingInfo.action#ended">已结束的会议</a></li>
							<li><a href="myMeetingInfo.action#cancel">已取消的会议</a></li>
						</ul>
					</li>

					<li class="dropdown"><a class="dropdown-toggle"
						data-toggle="dropdown" href="#"> 申请会议<span class="caret"></span>
					</a>
						<ul class="dropdown-menu">
							<li><a href="applyByTimeAndNumber.action">通过时间和容量</a>
							</li>
							<li><a href="applyMeetingByAddress.action">通过地点</a>
							</li>
						</ul>
					</li>
					<li><a href="personalInfo.action">
							个人信息</a>
					</li>
					<li><a href="getInvitationInfo.action">
							<span class="badge pull-right" id="mCount"></span>消息</a>
					</li>
			<c:if test="${sessionScope.adminFlag == '1'}">
						<li><a type="button" data-toggle="collapse" data-target="#admin">管理功能</a></li>
						</c:if>
				</ul>
				<div id="admin"  class="collapse in">
					<ul class="nav nav-pills nav-stacked">
						<li><a href="getPersonAction.action">人员管理</a>
						</li>
						<li><a href="GetMeetingRoomAction.action"><span
								class="badge pull-right"></span>会议室管理</a>
						</li>
						<li><a href="getDeviceAction.action"><span
								class="badge pull-right"></span>设备管理</a>
						</li>
						<li  class="active"><a href="getDepartmentAction.action"><span
								class="badge pull-right"></span>部门管理</a>
						</li>
						<li><a href="GetMeetingAction.action"><span
								class="badge pull-right"></span>会议管理</a>
						</li>
					</ul>
				</div>
				<!-- 管理界面 -->


			</div>
			<!--  -->
		</div>
  <div class="col-sm-10">
  <ol class="breadcrumb">
  <li><a href="myMeetingInfo.action">主页</a></li>
  <li class="active">部门管理</li>
</ol>

<c:if test="${addisSuccess=='true'}">
 <div class="alert alert-success alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  <strong>提示！</strong>部门添加成功！
</div>
</c:if>

<c:if test="${ModifyisSuccess=='true'}">
 <div class="alert alert-success alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  <strong>提示！</strong>部门修改成功！
</div>
</c:if>

<c:if test="${DelisSuccess=='true'}">
 <div class="alert alert-success alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  <strong>提示！</strong>部门删除成功！
</div>
</c:if>

<div class="panel panel-info">
  <div class="panel-heading col-sm-12">
     <h3 class="panel-title col-sm-4"  style="margin-top: 10px;padding-left: 0px;">部门信息</h3>
    <div class="col-sm-8 pull-right">
  <button type="button" class="btn btn-default pull-right"
  data-toggle="modal" data-target="#inviteModal">
  <span class="glyphicon glyphicon-plus"></span> 添加
  </button>
						<!-- /input-group -->
					</div>
    
  </div>
  <table class="table table-striped table-bordered" >

 <tr align="center">
 <td>部门编号</td>
 <td>部门名称</td>
 <td>人数</td>
   <td>操作</td>
 </tr>
 
<s:iterator value="departmentMes" var="deMes">
 <tr align="center">
 <td>${deMes.deId}</td>
 <td>${deMes.deName}</td>
 <td>${deMes.num}</td>
 
 <td>
 <button type="button" class="btn btn-default btn-xs"
 data-toggle="modal" data-target="#ModifyModal" onclick="FindID(${deMes.deId})">修改</button><button type="button" class="btn btn-danger btn-xs"
 data-toggle="modal" data-target="#confirmModal" onclick="FindDelID(${deMes.deId})">删除</button>
 
 </td>
 </tr>
</s:iterator>
  
</table>
<div align="center">
	<ul class="pager">
					<c:choose>
					<c:when test="${startPage-1<0}">
					<li class="disabled"><a href="#">上一页</a></li>
					</c:when>
					<c:otherwise>
					<li><a href="getDepartmentAction.action?startPage=${startPage-1}">上一页</a></li>
					</c:otherwise>
					</c:choose>
					<c:choose>
					<c:when test="${(startPage+1)*6>account}">
					<li  class="disabled"><a href="#">下一页</a></li>
					</c:when>
					<c:when test="${account<=6}">
					<li  class="disabled"><a href="#">下一页</a></li>
					</c:when>
					<c:otherwise>
					<li><a href="getDepartmentAction.action?startPage=${startPage+1}">下一页</a></li>
					</c:otherwise>
					</c:choose>
	</ul>
</div>
</div>
</div>
</div>

<div class="modal fade" id="inviteModal">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
					</button>
					<h4 class="modal-title">部门信息</h4>
				</div>
				<div class="modal-body">
				<form action="addDepartmentAction" method="post">
				<div class="row" style="margin-top:10px;margin-left: 50px;margin-right: 50px">
					<div class="input-group input-group-xs" style="margin-bottom: 10px">
  						<span class="input-group-addon"><span class="glyphicon glyphicon-home"></span></span>
  						<input type="text" class="form-control" placeholder="部门名称" name="deName">
				    </div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					<button type="submit" class="btn btn-primary">确定</button>
				</div>
				</form>
			</div>
		   </div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<!-- /.modal -->
	
	<div class="modal fade" id="ModifyModal">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
					</button>
					<h4 class="modal-title">部门信息</h4>
				</div>
				<div class="modal-body">
				<form action="modifyDepartmentAction" method="post">
				<div class="row" style="margin-top:10px;margin-left: 50px;margin-right: 50px">
					<div class="input-group input-group-xs" style="margin-bottom: 10px">
  						<span class="input-group-addon"><span class="glyphicon glyphicon-home"></span></span>
  						<input type="text" class="form-control" placeholder="部门名称" name="deName">
  						<input type="text" class="hide" id="deID" name="deID">
				    </div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					<button type="submit" class="btn btn-primary">确定</button>
				</div>
				</form>
			</div>
		   </div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<!-- /.modal -->
	
	<div class="modal fade" id="confirmModal">
		<div class="modal-dialog">
			<div class="modal-content">
			<form action="deleteDepartmentAction" method="post">
				<div class="modal-body">
					<h4>你确定要删除该部门吗？</h4>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					<button type="submit" class="btn btn-danger">确定</button>
					<input type="text" class="hide" name="delDeID" id="delDeID">
				</div>
				</form>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<!-- /.modal -->
	
</body>
<script src="js/jquery-2.0.1.min.js"></script>
<script src="js/bootstrap.js"></script>
<script type="text/javascript">
	function FindID(depmentID){
		var deID = document.getElementById("deID")
		deID.value = depmentID;
	}
	function FindDelID(depID){
		var deID = document.getElementById("delDeID");
		deID.value = depID;
	}
	function loadMessageCount(){
		loadMessageCount_request = false;
		var url="getNewMessage.do";
		if(window.XMLHttpRequest){
			loadMessageCount_request = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){
			try{
				loadMessageCount_request=new ActiveXObject("Msxm12.XMLHTTP");
			}catch (e){
				try{
					loadMessageCount_request=new ActiveXObject("Microsoft.XMLHTTP");
				}catch (e){}
			}
		}
		if(!loadMessageCount_request){
			alert("不能创建X对象");
			return false;
		}
		loadMessageCount_request.onreadystatechange = function(){
			loadMes();
		};
		loadMessageCount_request.open('GET', url, true);
		loadMessageCount_request.send(null);
	}
	
	function loadMes(){
		if(loadMessageCount_request.readyState==4){
			if(loadMessageCount_request.status==200){
				var arr = loadMessageCount_request.responseText;
				var jsonss  =eval("("+arr+")");
				var mCount=document.getElementById("mCount");
				if(jsonss[0]!=0) mCount.innerHTML=jsonss[0];
				}//200
				
				}//4
			
	}//function
</script>
</html>